/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.service.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ruipengkj.bean.TShopRecharge;
import com.ruipengkj.commons.base.query.PageModel;
import com.ruipengkj.dao.TShopRechargeDao;
import com.ruipengkj.service.TShopRechargeService;
/**
 * 说明：
 * 单据商品明细Service层接口实现
 * @Author：李智深
 * @Date：2012-03-16
 */
@Service
public class TShopRechargeServiceImpl implements TShopRechargeService{

	@Resource
	private TShopRechargeDao tShopRechargeDao;//DAO层
	
	//根据条件查询
	@Override
	public List<TShopRecharge> findService(TShopRecharge entity) throws Exception {
		String hql = "select o from TShopRecharge o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		List<TShopRecharge> list=tShopRechargeDao.findDao(hql, whereHQL.toString(), param, orderby);
		return list;
	}
	//根据条件删除
	@Override
	public boolean deleteService(TShopRecharge entity) throws Exception {
		String hql = "select o from TShopRecharge o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		List<TShopRecharge> list=tShopRechargeDao.findDao(hql, whereHQL.toString(), param, null);
		if(list!=null&&list.size()!=0){
			for(int i = list.size()-1; i >= 0 ; --i) {
				TShopRecharge com=list.get(i);
				if(com!=null){
					tShopRechargeDao.deleteDao(com.getRechargeID());
				}
			}
			return true;
		}
		return false;
	}

	//根据ID翻页查询
	@Override
	public PageModel<TShopRecharge> getScrollService(int firstResult,
			int maxResult, TShopRecharge entity) throws Exception {
		String hql = "select o from TShopRecharge o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return tShopRechargeDao.getScrollDao(hql, whereHQL.toString(), param, firstResult, maxResult, orderby);
	}

	
	//修改
	@Override
	public void modifyService(TShopRecharge entity) throws Exception {
		tShopRechargeDao.modifyDao(entity);
		
	}
	//添加
	@Override
	public void saveService(TShopRecharge entity) throws Exception {
		tShopRechargeDao.saveDao(entity);
	}

	//根据ID删除
	@Override
	public void deleteService(String id) throws Exception {
		tShopRechargeDao.deleteDao(id);
		
	}
	//根据ID查询
	@Override
	public TShopRecharge getByIdService(String id) throws Exception {
		return tShopRechargeDao.getByIdDao(id);
	}
	//添加或修改
	@Override
	public void saveOrUpdateService(TShopRecharge entity) throws Exception {
		tShopRechargeDao.saveOrUpdateDao(entity);
	}
	//添加返回ID
	@Override
	public Serializable saveRetService(TShopRecharge entity) throws Exception {
		return tShopRechargeDao.saveRetDao(entity);
	}
	public TShopRechargeDao gettBillDetailDao() {
		return tShopRechargeDao;
	}

	public void settBillDetailDao(TShopRechargeDao tShopRechargeDao) {
		this.tShopRechargeDao = tShopRechargeDao;
	}
	@Override
	public PageModel<TShopRecharge> getScrollService(int firstResult,
			int maxResult, int type) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}
}
